package ar.edu.unicen.pladema.ui.mouseListener;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;

import ar.edu.unicen.pladema.ui.model.points.ScreenPoint;
import ar.edu.unicen.pladema.ui.panel.options.IMoveIt;
import ar.edu.unicen.pladema.ui.panel.options.IPaintIt;
import ar.edu.unicen.pladema.ui.panel.options.IZoomIt;

public class VCMouseListener implements MouseListener {
	private ScreenPoint from;
	private ScreenPoint to;
	private IMoveIt moveIt;
	private IPaintIt paintIt;
	private IZoomIt zoomIt;
	public VCMouseListener(IMoveIt imi, IPaintIt ipi, IZoomIt izi) {
		this.moveIt = imi;
		this.paintIt = ipi;
		this.zoomIt = izi;
	}

	@Override
	public void mouseDoubleClick(MouseEvent e) {

	}

	@Override
	public void mouseDown(MouseEvent e) {
		from = new ScreenPoint(e.x, e.y);
	}

	@Override
	public void mouseUp(MouseEvent e) {
		to = new ScreenPoint(e.x, e.y);
		System.out.println("click! button:" + e.button
				+ " from:" + from.toString() 
				+ " to:" + to.toString());
		switch (e.button) {
			case 1: {
				zoomIt.doZoom(from, to);
				paintIt.doPaint();
				break;
			}
			case 3: {
				moveIt.doMove(from, to);
				paintIt.doPaint();
				break;
			}
			default: break;
		}
		from = null;
		to = null;

	}
}
